# -*- coding: utf-8 -*-
#
# Author:: Jonny
# Date:: 2022/6/18
import time

from submodules.common.lib.datetime_ import get_timestamp
from submodules.common.lib.log_ import get_logger

logger = get_logger()


def count_exec_time(func):
    def inner_func(*args, **kwargs):
        start = time.time()
        res = func(*args, **kwargs)
        end = time.time()
        logger.info(f"{func.__name__}()执行花费{round(float(end - start), 2)}秒")
        return res

    return inner_func


if __name__ == "__main__":

    @count_exec_time
    def test():
        time.sleep(1)
        return 123

    res = test()
    print(res)
